home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / man / cat.n / upvar.n < prev    next >
Text File  |  1995-07-25  |  4KB  |  132 lines

  1.  
  2.  
  3.  
  4.      uuuuppppvvvvaaaarrrr((((nnnn))))                     TTTTccccllll (((( ))))                     uuuuppppvvvvaaaarrrr((((nnnn))))
  5.  
  6.  
  7.  
  8.      _________________________________________________________________
  9.  
  10.      NNNNAAAAMMMMEEEE
  11.           upvar - Create link to variable in a different stack frame
  12.  
  13.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  14.           uuuuppppvvvvaaaarrrr ?_l_e_v_e_l? _o_t_h_e_r_V_a_r _m_y_V_a_r ?_o_t_h_e_r_V_a_r _m_y_V_a_r ...?
  15.      _________________________________________________________________
  16.  
  17.  
  18.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  19.           This command arranges for one or more local variables in the
  20.           current  procedure  to  refer  to  variables in an enclosing
  21.           procedure call or to global variables.  _L_e_v_e_l may  have  any
  22.           of  the  forms permitted for the uuuupppplllleeeevvvveeeellll command, and may be
  23.           omitted if the first letter of the first _o_t_h_e_r_V_a_r isn't #### or
  24.           a  digit  (it  defaults  to 1111).  For each _o_t_h_e_r_V_a_r argument,
  25.           uuuuppppvvvvaaaarrrr makes the variable by that name in the procedure frame
  26.           given  by  _l_e_v_e_l  (or  at  global  level,  if  _l_e_v_e_l  is ####0000)
  27.           accessible in the current procedure by the name given in the
  28.           corresponding   _m_y_V_a_r   argument.   The  variable  named  by
  29.           _o_t_h_e_r_V_a_r need not exist at the time of the call;  it will be
  30.           created  the  first  time  _m_y_V_a_r is referenced, just like an
  31.           ordinary variable.  UUUUppppvvvvaaaarrrr may only be  invoked  from  within
  32.           procedures.   _M_y_V_a_r may not refer to an element of an array,  |
  33.           but _o_t_h_e_r_V_a_r may refer to an array element.   UUUUppppvvvvaaaarrrr  returns
  34.           an empty string.
  35.  
  36.           The uuuuppppvvvvaaaarrrr command simplifies the implementation of  call-by-
  37.           name procedure calling and also makes it easier to build new
  38.           control constructs as Tcl procedures.  For example, consider
  39.           the following procedure:
  40.  
  41.                pppprrrroooocccc aaaadddddddd2222 nnnnaaaammmmeeee {{{{
  42.                    uuuuppppvvvvaaaarrrr $$$$nnnnaaaammmmeeee xxxx
  43.                    sssseeeetttt xxxx [[[[eeeexxxxpppprrrr $$$$xxxx++++2222]]]]
  44.                }}}}
  45.           AAAAdddddddd2222 is invoked with  an  argument  giving  the  name  of  a
  46.           variable,  and  it  adds  two to the value of that variable.
  47.           Although aaaadddddddd2222 could  have  been  implemented  using  uuuupppplllleeeevvvveeeellll
  48.           instead  of uuuuppppvvvvaaaarrrr, uuuuppppvvvvaaaarrrr makes it simpler for aaaadddddddd2222 to access
  49.           the variable in the caller's procedure frame.
  50.  
  51.           If an upvar variable is unset (e.g. xxxx in  aaaadddddddd2222  above),  the  |
  52.           uuuunnnnsssseeeetttt  operation  affects  the variable it is linked to, not  |
  53.           the upvar variable.  There is  no  way  to  unset  an  upvar  |
  54.           variable  except  by  exiting  the  procedure in which it is  |
  55.           defined.  However, it  is  possible  to  retarget  an  upvar  |
  56.           variable by executing another uuuuppppvvvvaaaarrrr command.
  57.  
  58.  
  59.  
  60.  
  61.      Page 1                                          (printed 7/17/95)
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.      uuuuppppvvvvaaaarrrr((((nnnn))))                     TTTTccccllll (((( ))))                     uuuuppppvvvvaaaarrrr((((nnnn))))
  69.  
  70.  
  71.  
  72.      KKKKEEEEYYYYWWWWOOOORRRRDDDDSSSS
  73.           context, frame, global, level, procedure, variable
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.      Page 2                                          (printed 7/17/95)
  128.  
  129.  
  130.  
  131.